﻿package mortal.game.view.rebate.item
{
    import Message.Public.*;
    import com.mui.controls.*;
    import flash.geom.*;
    import mortal.common.swfPlayer.*;
    import mortal.common.swfPlayer.data.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;

    public class RebateItem extends GSprite
    {
        protected var _item:BaseItem;
        protected var _effect:SWFPlayer;
        private var _txtStrenLv:BitmapNumberText;

        public function RebateItem()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._item = UIFactory.getUICompoment(BaseItem, 0, 0, this);
            this._item.setItemStyle(ItemStyleConst.Big, ImagesConst.ShopItemBg, 6, 6);
            this._item.isDragAble = false;
            this._item.isShowLock = true;
            this._effect = UIFactory.getUICompoment(SWFPlayer);
            this._effect.move(36, 33);
            this._effect.timeRate = 5;
            this.addChild(this._effect);
            this._item.isShowStreng = false;
            this._txtStrenLv = UIFactory.bitmapNumberText(41, 52, "EquipmentTipsNumber.png", 16, 16, -5, this);
            this._txtStrenLv.text = "";
            var _loc_1:Boolean = true;
            this.mouseChildren = true;
            this.mouseEnabled = _loc_1;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._item.dispose(param1);
            this._effect.dispose(param1);
            this._item = null;
            this._effect = null;
            this._txtStrenLv.dispose(param1);
            this._txtStrenLv = null;
            this.mouseEnabled = false;
            return;
        }// end function

        public function updateInfo(param1:SPlayerItem) : void
        {
            this._effect.stop();
            var _loc_2:* = new ItemData(param1.itemCode);
            _loc_2.itemAmount = param1.itemAmount;
            if (_loc_2.itemInfo)
            {
                if (ItemsUtil.isEquip(_loc_2))
                {
                    if (_loc_2.extInfo != null)
                    {
                        this.updateStrengLevel(_loc_2.extInfo.strengthen);
                    }
                }
                else if (ItemsUtil.isOtherEquip(_loc_2))
                {
                    if (_loc_2 && _loc_2.itemInfo && _loc_2.itemInfo.itemLevel > 1)
                    {
                        this.updateStrengLevel(_loc_2.itemInfo.itemLevel);
                    }
                    else
                    {
                        this.updateStrengLevel(0);
                    }
                }
                else
                {
                    this.updateStrengLevel(0);
                }
            }
            this._item.itemData = _loc_2;
            if (_loc_2.itemInfo && _loc_2.itemInfo.color >= 4)
            {
                this._effect.move(36, 33);
                this._effect.load("ArriundEffect_cheng_big.swf", ModelType.NormalSwf, null);
            }
            else
            {
                this._effect.move(33, 38);
                this._effect.load("ArriundEffect_zhi_big.swf", ModelType.NormalSwf, null);
            }
            return;
        }// end function

        public function flyIcon() : void
        {
            var _loc_1:* = this._item.localToGlobal(GameConst.yellowPoint);
            FlyToNavbarTool.flyBitmapOriginalToPack(this._item.bitmapdata, _loc_1);
            return;
        }// end function

        public function showEffect(param1:Boolean) : void
        {
            if (this._effect)
            {
                if (param1)
                {
                    this._effect.play();
                    this._effect.visible = true;
                }
                else
                {
                    this._effect.stop();
                    this._effect.visible = false;
                }
            }
            return;
        }// end function

        public function updateStrengLevel(param1:int = 0) : void
        {
            if (param1 != 0)
            {
                this._txtStrenLv.text = "+" + param1;
                this._txtStrenLv.x = this.width - this._txtStrenLv.width;
                this._txtStrenLv.y = this.height - this._txtStrenLv.height - 2;
            }
            else
            {
                this._txtStrenLv.text = "";
            }
            return;
        }// end function

    }
}
